package org.lansir.af.dataview;

import java.util.Calendar;

import org.lansir.af.ui.CommonFragment;

import android.media.AudioManager;

/**
 * 
 * @author 蓝智宏
 *
 */
public class DataViewItemActivity extends DataViewItem{
	
	private String sSubject = "";
	private String sLocation = "";
	private String sOrganizer = "";
	private Calendar calStartDate = Calendar.getInstance();
	
	private long lRepeatEndOnDate = 0;
	private boolean bAlarm;
	private int iRepeatType = 0;
	private int iRepeatEvery = 1;
	private int iSnooze;
	private int iSnoozeCount;
	private int iActionClear;
	private int dayType = CommonFragment.ViewType.NONE;
	private int iRingerMode = AudioManager.RINGER_MODE_NORMAL;
	
	public long lRepeatDaysBitMask = 0;
	
	public void clear() {
		lRepeatDaysBitMask = 0;
	}
	
	public void setVisibleDay(int iDay) {
		lRepeatDaysBitMask |= 0x01L << iDay;
	}

	public boolean getVisibleDay(int iDay) {
		long bitMask = 0x01L << iDay;
		return ((lRepeatDaysBitMask & bitMask) != 0);
	}

	public long getVisibleDays() {
		return lRepeatDaysBitMask;
	}
	
	public boolean isRepeat() {
		return (iRepeatType > 0);
	}

	public boolean useRepeatEndOnDate() {
		return (lRepeatEndOnDate > 0);
	}
	public long getStartDateAsLong() {
		return this.calStartDate.getTimeInMillis();
	}
	
	public Calendar getStartDate(){
		return this.calStartDate;
	}
	
	public int getStartHour() {
		return this.calStartDate.get(Calendar.HOUR_OF_DAY);
	}

	public int getStartMinute() {
		return this.calStartDate.get(Calendar.MINUTE);
	}

	public void setStartDate(Calendar calUtilDate, long lStartDate) {
		calUtilDate.setTimeInMillis(lStartDate);
		this.calStartDate.setTimeInMillis(lStartDate);
	}

	
	public int getTimeKey() {
		return (getStartHour() * 100) + getStartMinute();
	}
	
	public int getTimeAsSeconds() {
		return (calStartDate.get(Calendar.MINUTE) * 60) + (calStartDate.get(Calendar.HOUR_OF_DAY) * 3600);
	}

	public String getSubject() {
		return sSubject;
	}

	public void setSubject(String subject) {
		sSubject = subject;
	}

	public String getLocation() {
		return sLocation;
	}

	public void setLocation(String location) {
		sLocation = location;
	}


	public void setStartDate(long startDate) {
		this.calStartDate.setTimeInMillis(startDate);
	}

	public long getRepeatEndOnDate() {
		return lRepeatEndOnDate;
	}

	public void setRepeatEndOnDate(long repeatEndOnDate) {
		lRepeatEndOnDate = repeatEndOnDate;
	}

	public boolean isAlarm() {
		return bAlarm;
	}

	public void setAlarm(boolean alarm) {
		bAlarm = alarm;
	}

	public int getRepeatType() {
		return iRepeatType;
	}

	public void setRepeatType(int repeatType) {
		iRepeatType = repeatType;
	}

	public int getRepeatEvery() {
		return iRepeatEvery;
	}

	public void setRepeatEvery(int repeatEvery) {
		iRepeatEvery = repeatEvery;
	}

	public int getRingerMode() {
		return iRingerMode;
	}

	public void setRingerMode(int ringerMode) {
		iRingerMode = ringerMode;
	}

	public int getDayType() {
		return dayType;
	}

	public void setDayType(int dayType) {
		this.dayType = dayType;
	}
	
	public int getSnooze() {
		return iSnooze;
	}

	public void setSnooze(int snooze) {
		iSnooze = snooze;
	}

	public int getSnoozeCount() {
		return iSnoozeCount;
	}

	public void setSnoozeCount(int snoozeCount) {
		iSnoozeCount = snoozeCount;
	}

	public int getActionClear() {
		return iActionClear;
	}

	public void setActionClear(int actionClear) {
		iActionClear = actionClear;
	}

	public boolean timeOverdue(int iCurrTimeKey) {
		if (iCurrTimeKey >= getTimeKey())
				return true;
		return false;
	}

	public String getOrganizer() {
		return sOrganizer;
	}

	public void setOrganizer(String organizer) {
		sOrganizer = organizer;
	}
	
	
	
}
